package com.aierkeji.b2c.controller;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.aierkeji.b2c.service.AkjOrderService;
import com.aierkeji.b2c.service.AlipayService;
import com.aierkeji.b2c.utils.ResultMapHelper;
import com.aierkeji.b2c.utils.StringUtils;

/**
 * 专门给CMS服务调用的接口类
 * @author jin
 *
 */

@RestController
@RequestMapping(value = "cmsApi")
public class AkjCMSController extends BaseController {
	@Autowired
	private AlipayService alipayService;
	@Autowired
	private AkjOrderService akjOrderService;

	
	/**
	 * 预授权解冻接口
	 * 
	 * @param 
	 * @return
	 */
	@PostMapping("/unfreeze")
	public Map<String, Object> unfreeze(@RequestBody Map<String,Object> params,HttpServletRequest request) {	
		
		
		 return alipayService.fundAuthOrderUnFreeze_in(params);
	}

	/**
	 * 预授权转支付接口
	 * 
	 * @param 
	 * @return
	 */
	@PostMapping("/tradePay")
	public Map<String, Object> tradePay(@RequestBody Map<String,Object> params,HttpServletRequest request) {		 
		 return alipayService.tradePay_in(params);
	}
	
	
	
	
	/**
	 * 退款接口
	 * 
	 * @param 
	 * @return
	 */
	@PostMapping("/tradeRefund")
	public Map<String, Object> tradeRefund(@RequestBody Map<String,Object> params,HttpServletRequest request) {		 
		 return alipayService.tradeRefund_in(params);
	}
	
	/**
	 * 测试查询接口
	 * 
	 * @param 
	 * @return
	 */
	@PostMapping("/query")
	public Map<String, Object> query(@RequestBody Map<String,Object> params,HttpServletRequest request) {		 
		String id = (String)params.get("id");
		String pId = (String)params.get("pid");
		 return akjOrderService.query(pId,id);
	}
	
	
}
